
package com.probiz.estore.exception;

import com.probiz.estore.common.model.sales.Coupon;
import com.probiz.estore.core.util.I18nUtil;

public class CouponStateException extends Exception {

	private static final long	serialVersionUID	= 1L;
	private String				couponNo;
	private short				state				= Coupon.STATE_INVALID;

	public CouponStateException() {
		super();
	}

	public CouponStateException(String couponNo, short state) {
		super();
		this.setCouponNo(couponNo);
		this.setState(state);
	}

	public short getState() {
		return state;
	}

	public void setState(short state) {
		this.state = state;
	}

	public String getCouponNo() {
		return couponNo;
	}

	public void setCouponNo(String couponNo) {
		this.couponNo = couponNo;
	}
	
	@Override
	public String getMessage() {
		switch (state) {
			case Coupon.STATE_INVALID: {
				return I18nUtil.getInstance().getMessage("shoppingcart.coupon_STATE_INVALID");
			}
			case Coupon.STATE_INVALID_NOT_ACTIVE: {
				return I18nUtil.getInstance().getMessage("shoppingcart.coupon_STATE_INVALID_NOT_ACTIVE");
			}
			case Coupon.STATE_INVALID_IS_END: {
				return I18nUtil.getInstance().getMessage("shoppingcart.coupon_STATE_INVALID_IS_END");
			}
			case Coupon.STATE_INVALID_NOT_START: {
				return I18nUtil.getInstance().getMessage("shoppingcart.coupon_STATE_INVALID_NOT_START");
			}
			case Coupon.STATE_INVALID_REMAINEDTIMES_IS_ZERO: {
				return I18nUtil.getInstance().getMessage("shoppingcart.coupon_STATE_INVALID_REMAINEDTIMES_IS_ZERO");
			}
			default: {
				return "Unknow coupon state error.";
			}
		}
	}

}
